def get_default(data_dict, key, default):
    if key not in data_dict.keys():
        return default
    if data_dict.get(key) is None:
        return default
    return data_dict.get(key)


def put_list(data_dict, key, value):
    if key not in data_dict.keys():
        data_dict[key] = [value]
    elif not isinstance(data_dict.get(key), list):
        raise Exception(print('插入list的形态不对'))
    else:
        data_dict[key].append(value)


def put_int_add(data_dict, key, add: int):
    if key not in data_dict.keys():
        data_dict[key] = add
    elif not isinstance(data_dict.get(key), int):
        raise Exception(print('非int类型不能add'))
    else:
        data_dict[key] += add


def put_list_count(data_dict, key, value):
    if key not in data_dict.keys():
        data_dict[key] = [value]
        data_dict[key + ':count'] = 1
    elif not isinstance(data_dict.get(key), list):
        raise Exception(print('插入list的形态不对'))
    else:
        data_dict[key].append(value)
        data_dict[key + ':count'] += 1
